package com.jcl.traffic.system.rest;

import com.jcl.traffic.system.domain.BreakRule;
import com.jcl.traffic.system.service.BreakRuleService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author jcl_hqu
 * @date 2021/3/8 17:27
 */

@Controller
@RequiredArgsConstructor
@RequestMapping("admin/BreakRules")
public class BreakRuleController {
    private final BreakRuleService breakRuleService;
    @RequestMapping("/list")
    public String listBreakRules(Model model){
        List<BreakRule> breakRules = breakRuleService.listBreakRule();
        model.addAttribute("users",breakRules);
        return "break_rules";
    }

    @RequestMapping("delete")
    public String deleteBreakRules(Long id){
        breakRuleService.deleteBreakRule(id);
        return "redirect:admin/BreakRules/list";
    }
}
